package docchepfile;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class CopyFile {
	public void copy(String from, String to) throws Exception{
		FileInputStream fi=null;
		FileOutputStream fo=null;
		
		try{
			fi=new FileInputStream(from);
			fo=new FileOutputStream(to);
			
			byte []buff=new byte [1024];
			int len=0;
			while ((len=fi.read(buff))!=-1){
				fo.write(buff, 0, len);
				fo.flush();
			}
			System.out.println("hoan thanh...");
		}catch (Exception e){
			e.printStackTrace();
		}
		finally{
			if (fi!=null)fi.close();
			if (fo!=null)fo.close();
		}
	}
	public static void main (String [] args) throws Exception {
		new CopyFile().copy("C:/Users/hao huynh/Desktop/copy.txt", "F:/chep.txt");
	}
}
